package io.demo.hallelujahspring5;


import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author lijinting01
 */
@Configuration
public class QuartzConfig {
	@Bean
	public JobDetail jobDetail() {
		return JobBuilder.newJob(SomeJob.class)
				.storeDurably(true)
				.withIdentity("job1", "group1")
				.withDescription("Testing job")
				.build();
	}

	@Bean
	public Trigger trigger(JobDetail jobDetail) {
		return TriggerBuilder.newTrigger()
				.withIdentity("trigger1", "group1")
				.forJob(jobDetail)
				.startNow()
				.withSchedule(
						SimpleScheduleBuilder.simpleSchedule()
								.withIntervalInSeconds(2)
								.withRepeatCount(10)
				)
				.build();
	}
}
